#include <iostream>
#include <zlib/lib/Ink_syslim.h>
#include <stdlib.h>
using namespace std;

//this example mast use root permisson

int main()
{
	struct rlimit lim;
	if(get_fd_limit(&lim) != 0)
	{
		cout << "get fd limit error" << endl;
		exit(1);
	}else{
		cout << "fd limit:" << lim.rlim_cur << endl;
	}

	if(set_fd_limit(100000) != 0)
	{
		cout << "set fd limit error" << endl;
		exit(1);
	}else{
		if(get_fd_limit(&lim) != 0)
		{
			cout << "set fd and get fd limit error";
			exit(1);
		}else{
			cout << "after set fd limit, the fd limit is " << lim.rlim_cur << endl;
		}
	}

	//teting core dump
	if(set_core_size(10000) != 0)
	{
		cout << "set core size faild" << endl;
		exit(1);
	}else{
		cout << "testing core dump" << endl;
		//testing...
		char *p = "abdef";
		p[0] = 'e';
	}

	
	return 0;
}
